/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-12 09:58:14
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-19 09:24:43
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/model/home/module_model.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';

import '../../../../constants.dart';

class MenuItem extends StatelessWidget {
  const MenuItem({
    Key key,
    this.module,
    this.index,
    this.color,
  }) : super(key: key);
  final ModuleModel module;
  final int index;
  final Color color;

  @override
  Widget build(BuildContext context) {
    Alignment alignment;
    switch (index % 3) {
      case 0:
        alignment = Alignment.centerLeft;
        break;
      case 1:
        alignment = Alignment.center;
        break;
      case 2:
        alignment = Alignment.centerRight;
        break;
      default:
    }
    return Material(
      color: Colors.transparent,
      child: Container(
        alignment: alignment,
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            InkWell(
              borderRadius: BorderRadius.circular(defaultRadius),
              splashColor: Color(0xffF8FAFB),
              onTap: () {
                Get.toNamed("/${module.module}");
              },
              child: Container(
                width: 60,
                height: 60,
                padding: EdgeInsets.all(defaultPadding),
                decoration: BoxDecoration(
                  color: Color(0xffF8FAFB).withOpacity(0.8),
                  borderRadius: BorderRadius.circular(defaultRadius),
                ),
                child: SvgPicture.asset(
                  "assets/icon/${module.svg}",
                  width: 30,
                  height: 30,
                  color: color,
                ),
              ),
            ),
            SizedBox(height: 12),
            Text(
              "${module.menu}",
              style: TextStyle(
                fontSize: 14,
              ),
            ),
          ],
        ),
      ),
    );
  }
}
